Release 10.1A: OpenEdge Data Management:
SQL Reference
Quantified Predicate
The quantified predicate compares a value with a collection of values using a relational operator. A quantified predicate has the same form as a basic predicate with the query_expression being preceded by the ALL, ANY, or SOME keyword. The result table returned by query_expression can contain only a single column.
When you specify ALL, the predicate evaluates to true if the query_expression returns no values or the specified relationship is true for all the values returned.
When you specify SOME or ANY, the predicate evaluates to true if the specified relationship is true for at least one value returned by the query_expression. There is no difference between the SOME and ANY keywords. The predicate evaluates to false if the query_expression returns no values or if the specified relationship is false for all the values returned.
This is the syntax for a quantified_predicate:
Example
BETWEEN Predicate
The BETWEEN predicate can be used to determine if a value is within a specified value range or not. The first expression specifies the lower bound of the range and the second expression specifies the upper bound of the range.
The predicate evaluates to true if the value is greater than or equal to the lower bound of the range and less than or equal to the upper bound of the range.
This is the syntax for a between_predicate:
Example
NULL Predicate
The NULL predicate can be used for testing null values of database table columns.
This is the syntax for a null_predicate.
Example
LIKE Predicate
The LIKE predicate searches for strings that have a certain pattern. The pattern is specified after the LIKE keyword in a string constant. The pattern can be specified by a string in which the underscore ( _ ) and percent sign ( % ) characters have special semantics.
Use the ESCAPE clause to disable the special semantics given to the characters ( _ ) and
( % ). The escape character specified must precede the special characters in order to disable their special semantics.This is the syntax for a like_predicate:
Note
Example
- The
column_namespecified in theLIKEpredicate can be a column, a string constant, or an arbitrary character expression (such asSUBSTRINGorLTRIM).- The
string_constantmay be a string constant or a scalar function call.- The
escape_charactermust be a one character string constant.- A percent sign ( % ) in the pattern matches zero or more characters of the column string.
- A underscore symbol ( _ ) in the pattern matches any single character of the column string.
- The
LIKEpredicate is multi-byte enabled. Thestring_constantand theescape_charactermay contain multi-byte characters, and theescape_charactercan be a multi-byte character. A percent sign ( % ) or an underscore ( _ ) in thestring_constantcan represent a multi-byte character. However, the percent sign or underscore itself must be the single-byte ASCII encoding.This example illustrates three ways to use the LIKE predicate:
In the first LIKE clause, for all strings with the substring ’Computer’ the predicate evaluates to true. In the second LIKE clause, for all strings which are exactly three characters long the predicate evaluates to true. In the third LIKE clause the backslash character ( \ ) is specified as the escape character, which means that the special interpretation given to the underscore character ( _ ) is disabled. The pattern evaluates to TRUE if the item_name column has embedded underscore characters.
EXISTS Predicate
The EXISTS predicate can be used to check for the existence of specific rows. The query_expression returns rows rather than values. The predicate evaluates to true if the number of rows returned by the query_expression is nonzero.
This is the syntax for an exists_predicate:
Example
In this example, the predicate evaluates to true if the specified customer has any orders:
IN Predicate
The IN predicate can be used to compare a value with a set of values. If an IN predicate specifies a query expression, then the result table it returns can contain only a single column.
This is the syntax for an in_predicate:
Example
OUTER JOIN Predicate
An outer join predicate specifies two tables and returns a result table that contains all the rows from one of the tables, even if there is no matching row in the other table.
This is the syntax for an outer_join_predicate:
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |